<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles" %>
<%@ page import="java.util.Iterator" %>

<%-- Push tiles component attributes in page context  --%>
<tiles:importAttribute />

<table border="0" cellpadding="0" cellspacing="0">

<%-- Check if selected exist. --%>
<logic:notPresent name="selected" >
  <% pageContext.setAttribute( "selected", "" ); %>
</logic:notPresent>

<%-- Prepare the links list to be iterated --%>
<bean:define id="links" name="links" type="java.util.List" scope="page" ></bean:define>
<% Iterator i = links.iterator(); %>

<%-- iterate on items list --%>
<%-- Normally, we should write something like this :
   <logic:iterate id="item" name="items" type="java.lang.String" >
   But, Struts doesn't declare the TEI class for iterate, and
   some web container deal badly with the declared variable.
   So, we use what follow instead.
    --%>
<tr>
<td valign="middle" align="middle" width="1">
<html:img page="/images/common/clear.gif" width="20" height="1" border="0"/>
</td>
<td valign="middle" nowrap >
<% if(session.getAttribute("Login")== null){%>
   <html:link  page="/do/login" styleClass="mainmenu">
           <bean:message key="menu.link.app.login" />
    </html:link>
<%}else{%>
    <html:link page="/do/logoff" styleClass="mainmenu">
           <bean:message key="menu.link.app.logout"  />
    </html:link>
<%}%>

</td>

<logic:iterate id="iterateItem" name="items"  indexId="index">
<bean:define id="item" name="iterateItem" type="java.lang.String" scope="page"></bean:define>
  <% String link = (String)i.next(); %>
      <td width="20" valign="middle" align="middle">
      <span class='smalltextheader'>|</span>
      </td>
      <td valign="middle" nowrap >
        <%-- check if selected --%>
      <% // tilesute link value
        if(link.startsWith("/") )
          link = request.getContextPath() + link;

        String target = "";
        if(link.contains("/do/document/list")) target="_blank";
      %>
      <html:link href="<%=link%>" styleClass="mainmenu" target="<%=target%>">
      <bean:message key="<%=item%>"/>
      </html:link>
      </td>
  </ext:secure>
</logic:iterate>
<td width="20" valign="middle" align="middle"></td>
</tr>
</table>
